/*
 * jQuery UI WindowedDialogChild 0.5.1
 *
 * Depends:
 *	ui.core.js
 *  jquery-ui.windowedDialog.js
 */
(function($) {

$.ui.windowedDialogChild = {
	version: "0.5.1",
	_init: function() {
	    $.ui.windowedDialogChild.bindUnload();
	},
	setDialogResult: function(result) {
		try {
			$.ui.windowedDialogChild.unbindUnload();
			window.opener.jQuery.ui.windowedDialog.setDialogResult(window.name, result);
		}
		catch (err) {
			$.ui.windowedDialogChild.bindUnload();
			//window.alert(err);
		}
	},
	cancelDialog: function() {
		try {
			$.ui.windowedDialogChild.unbindUnload();
			window.opener.jQuery.ui.windowedDialog.cancelDialog(window.name);
		}
		catch (err) {
			$.ui.windowedDialogChild.bindUnload();
			//window.alert(err);
		}
	},
	unbindUnload: function() {
	    $(window).unbind('unload.windowedDialogChild');
	},
	bindUnload: function() {
		$(window).bind('unload.windowedDialogChild', function(evt){
				try {
        			$.ui.windowedDialogChild.unbindUnload();
					window.opener.jQuery.ui.windowedDialog.notifyUnload(window.name, evt);
				}
				catch (err) {
					$.ui.windowedDialogChild.bindUnload();
					//window.alert(err);
				}
			});
	}
};
$.ui.windowedDialogChild._init();
})(jQuery);

$setDialogResult = jQuery.ui.windowedDialogChild.setDialogResult;
$cancelDialog = jQuery.ui.windowedDialogChild.cancelDialog;
$bindUnload = jQuery.ui.windowedDialogChild.bindUnload;
$unbindUnload = jQuery.ui.windowedDialogChild.unbindUnload;